<%
  #File:    /app/views/manage/users/_address_info.rhtml
  #Author:  Andrew Stone
  #Created: 08.02.2006
%>
<%
  @addresses.each do |addr|
    if addr.type.is_required
      req = "* "
      cls = "req_"
    end %>
    <tr><td colspan="2"><hr/></td></tr>
    <tr>
      <td class="<%= cls%>list_label"><%= req%><%= addr.type.name%> Address:</td>
      <td class="data">
        <% 
          if edit_user %>
            <%= text_field_tag("address_#{addr.type.id}[line_one]",addr.data.line_one,{:size => 40})%><br/>
            <%= text_field_tag("address_#{addr.type.id}[line_two]",addr.data.line_two,{:size => 40})%> <% 
          else %>
            <%= h(addr.data.line_one)%><br/>
            <%= h(addr.data.line_two)%><%
          end %>
      </td>
    <tr>
      <td class="<%= cls%>label"><%= req%><%= addr.type.name%> City, State:</td>
      <td class="data">
        <% 
          if edit_user %>
            <%= text_field_tag("address_#{addr.type.id}[city]",addr.data.city)%>
            <select name="<%= "address_#{addr.type.id}[state_cd]"%>">
              <% STATES.each do |key,value| %>
              <option value="<%= key%>" <%= "selected" if addr.data.state_cd == key%>><%= value%></option>
              <% end %>
            </select><%
          else %>
            <%= h(addr.data.city)%>,
            <%= h(STATES[addr.data.state_cd])%><%
          end %>
      </td>
    </tr> 
    <tr>
      <td class="<%= cls%>label"><%= req%><%= addr.type.name%> Zip:</td>
      <td class="data">
        <% 
          if edit_user %>
            <%= text_field_tag("address_#{addr.type.id}[zip_code]",addr.data.zip_code,{:size => 10,:maxlength => 10})%><%
          else %>
            <%= h(addr.data.zip_code)%><%
          end %>
      </td>
    </tr>
    <%
      if @add_addresses.length > 0  && edit_user%>
        <tr>
          <td class="label">
            Additional Addresses:
          </td>
          <td class="data">
            <select name="add_address">
              <option/>
              <%= options_from_collection_for_select(@add_addresses,"id","name")%>
            </select>
            <%= submit_tag("Add Address")%>
          </td>
        </tr><%
      end
  end
%>

